package com.jsz.peini.vo;

import java.util.ArrayList;
import java.util.List;

import com.alibaba.fastjson.JSONObject;

public class MergedCommonTaskInfo {
	CommonTaskInfo topTask;
	List<CommonTaskInfo> taskList = new ArrayList<CommonTaskInfo>();
	
	public Integer getId(){
		return topTask.getId();
	}
	public Integer getSum() {
		return taskList.size();
	}
	public CommonTaskInfo getTaskObject() {
		return topTask;
	}
	public void setTopTask(CommonTaskInfo topTask) {
		this.topTask = topTask;
	}
	public void setTaskList(List<CommonTaskInfo> taskList) {
		this.taskList = taskList;
	}
	
	public Integer getRankType(){
		return 1;
	}
	
	public JSONObject getTasks(){
		StringBuilder taskIds = new StringBuilder();
		StringBuilder partyIds = new StringBuilder();
		JSONObject jsonObj = new JSONObject();
		for(CommonTaskInfo task : taskList){
			switch(task.getType()){
				case 1:
					taskIds.append(task.getId()).append(",");
				break;
				default :
					partyIds.append(task.getId()).append(",");
					break;
			}
		}
		jsonObj.put("taskIds", taskIds.toString());
		jsonObj.put("partyIds", partyIds.toString());
		return jsonObj;
	}
	
	public void add(CommonTaskInfo task){
		if(topTask == null) topTask = task;
		taskList.add(task);
	}
}
